package Action;

import domain.*;
import UserService.UserService;
import UserService.UserServiceImpl;
import java.util.List;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class Login extends ActionSupport {
	private TUser user;
	private UserService userService;
	public TUser getUser() {
		return user;
	}
	public void setUser(TUser user) {
		this.user = user;
	}
	public UserService getUserService() {
		return userService;
	}
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	public String Login(){
		List user1;
		userService = new UserServiceImpl();
		String sql="select s from TUser s where s.userId ='"+user.getUserId()+"' and s.upassword='"+user.getUpassword()+"'";
		user1 = userService.userLogin(sql);
		ActionContext con=ActionContext.getContext();
		con.getSession().put("user", user1);
		if(user1.size()>0){
			return "success";
		}else{
			return "fail";
		}
	}
}
